<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <?php
            echo $this->headMeta()->appendHttpEquiv('Content-Type', 'text/html; charset=utf-8');

            echo $this->headLink()->appendStylesheet('/ext/resources/css/ext-all.css')
                                  ->appendStylesheet('/css/layout.css');

            echo $this->headScript()->appendFile('/ext/adapter/ext/ext-base.js')
                                    ->appendFile('/ext/ext-all.js')
                                    ->appendFile('/js/global_layout.js')
                                    ->appendFile('/js/x_msg.js')
                                    ->appendFile('/js/x_form.js')
                                    ->appendFile('/js/x_grid.js')
                                    ->appendFile('/js/x_store.js')
                                    ->appendFile('/js/ext_rubro_editar.js');
        ?>
    </head>
    <body>
        <table class="layout">
            <tr><td id="layout_header"></td></tr>
            <tr><td id="layout_menu"></td></tr>
            <tr><td id="layout_content"></td></tr>
            <tr><td id="layout_footer"></td></tr>
        </table>
    </body>
    <script type="text/javascript">
        Ext.onReady(function()
        {
            try{
                 <?php X\MenuAdmin::Show(); ?>
                <?php  if ($this->error): ?>

                    <?php echo 'X.msg.FailureRedirect(' . json_encode($this->error) . ', "/usuario/listar");'; ?>

                <?php else: ?>
                    store_padres.setJson('<?php echo $this->jsonRubros;  ?>');

                    Ext.getCmp('rubroPK')         .setValue('<?php echo $this->rubro->getCodigoRubro(); ?>');
                    Ext.getCmp('nombreRubro')     .setValue('<?php echo $this->rubro->getNombre();      ?>');
                    Ext.getCmp('checkTerminal')   .setValue('<?php echo $this->rubro->getTerminal();    ?>');

                    Ext.getCmp('originalFullCodigo').setValue('<?php echo $this->codigoFull;               ?>');
                    Ext.getCmp('codigoActual')      .setValue('<?php echo $this->codigoFull;               ?>');

                    Ext.getCmp('cantHijos')       .setValue('<?php echo $this->cantHijos;               ?>');
                    Ext.getCmp('originalTipo')    .setValue('<?php echo $this->rubro->getEgreso()?'E':'I';?>');
                    Ext.getCmp('originalTerminal').setValue('<?php echo $this->rubro->getTerminal()     ;?>');

                    Ext.getCmp('originalPadre').setValue('<?php echo $this->originalPadre;        ?>');
                    Ext.getCmp('codigoNuevo')     .setValue('<?php echo $this->codigoFull;               ?>');
                    
                    //si el rubro no tiene padre, pasarle 0 (sin padre)
                    <?php if ($this->rubro->getPadre()): ?>
                        Ext.getCmp('rubroPadre')      .setValue('<?php echo $this->rubro->getPadre()->getCodigoRubro(); ?>');
                    <?php else: ?>
                        Ext.getCmp('rubroPadre')      .setValue(0);
                    <?php endif; ?>

                    //indicar si es del tipo egreso o ingreso
                    <?php if($this->rubro->getEgreso()): ?>
                        Ext.getCmp('radioE').setValue(true);
                        Ext.getCmp('tipo').setValue('E');
                    <?php else: ?>
                        Ext.getCmp('radioI').setValue(true);
                        Ext.getCmp('tipo').setValue('I');
                    <?php endif; ?>

                     //indicar si es de proposito general o especifico
                    <?php if($this->rubro->getGeneral()): ?>
                        Ext.getCmp('radioGral').setValue(true);
                        Ext.getCmp('proposito').setValue('G');
                    <?php else: ?>
                        Ext.getCmp('radioEspe').setValue(true);
                        Ext.getCmp('proposito').setValue('E');
                    <?php endif; ?>
                    
                <?php endif; ?>
            }
            catch(e){
                X.msg.FailureJs(e.message);
            }
        });
    </script>
</html>